CONTENTS | INDEX | PREV | NEXT
 getcwd

 NAME
  getcwd - get current working directory

 SYNOPSIS
  char *path = getcwd(buf, max);

  non-standard call

 FUNCTION
  Gets the current working directory and puts it into the specified
  buffer buf.  If buf is NULL it will be malloc()d automatically.
  buf is returned (or the malloced buffer if you passed NULL for buf).

  max specifies the maximum length of the path including the terminating
  nul character.

  NULL is returned if any error occurs (such as malloc failing)

 EXAMPLE
  #include <stdio.h>

  char buf[512];

  main(ac, av)
  int ac;
  char *av[];
  {
      getcwd(buf, sizeof(buf));
      printf("Current directory is: %sn", buf);
      return(0);
  }

 INPUTS
  char *buf;  buffer to place current directory path into or
          NULL if you want getcwd to allocate one

  int max;    maximum size of buffer

 RESULTS
  char *path; returns allocated buffer if you passed NULL for
          buf, else returns the first argument.  Returns
          NULL on error.

 SEE ALSO
  chdir